package IC.AST;

import java.util.LinkedList;

public class ClassDeclaration extends ASTNode
{
	private String _classID, _supertClassID;
	private LinkedList<ClassField> _listOfFields = new LinkedList<ClassField>();
	private LinkedList<Method> _listOfMethods = new LinkedList<Method>();

	public Object Visit(Visitor visitor) { return visitor.Visit(this); }
	
	public ClassDeclaration(Interval interval, String classID, String supreClassID, LinkedList<FieldsOrMethod> fieldsOrMethodList)
	{
		super(interval);
		_classID = classID;
		_supertClassID = supreClassID;
		
		for(FieldsOrMethod fieldOrMethod : fieldsOrMethodList)
		{
			if (fieldOrMethod instanceof Fields)
				for(ClassField field : ((Fields)fieldOrMethod).GetIds())
				{
					_listOfFields.add(field);
					field.SetASTType(((Fields)fieldOrMethod).GetASTType());
					GiveBirth(field);
				}
			else if (fieldOrMethod instanceof Method)
			{
				_listOfMethods.add((Method)fieldOrMethod);
				GiveBirth(fieldOrMethod);
			}
		}
	}
	
	public String GetID() { return new String(_classID); }
	public String GetSuperClassID() { return ((_supertClassID == null) ? null : new String(_supertClassID)); }
	public LinkedList<ClassField> GetFields() { return _listOfFields; }
	public LinkedList<Method> GetMethods() { return _listOfMethods; }

}
